package com.zhao.wechat.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * swagger配置
 */
@Configuration
@EnableOpenApi
@Slf4j
public class SwaggerConfig {

	/**
	 * 打印swagger状态
	 */
	SwaggerConfig(){
		log.info("启动swagger文档规范... ...");
	}


	@Bean
	public Docket desertsApi(){
		return new Docket(DocumentationType.OAS_30)
				.apiInfo(apiInfo())
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.zhao.wechat.rest"))
				.paths(PathSelectors.any())
				.build()
				.groupName("default")
				.enable(true);
	}

	private ApiInfo apiInfo(){
		return new ApiInfoBuilder()
				.title("微信天气问候API说明文档")
				.description("微信天气问候API说明文档")
				.contact(new Contact("stevezhao", "https://www.stevezhao.top", "909475162@qq.com"))
				.termsOfServiceUrl("https://www.stevezhao.top")
				.version("1.0")
				.build();
	}

}
